package com.wsc.playground.j2ee.brasil.superbolsa;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

import com.wsc.playground.j2ee.brasil.superbolsa.view.IbovespaView;
import com.wsc.playground.j2ee.brasil.superbolsa.view.IbovespaViewAction;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
    private IbovespaViewAction ibovespaViewAction;
    private IWorkbenchAction exitAction;

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(IWorkbenchWindow window) {
        // Creates the actions and registers them.
        // Registering is needed to ensure that key bindings work.
        // The corresponding commands keybindings are defined in the plugin.xml file.
        // Registering also provides automatic disposal of the actions when
        // the window is closed.

        exitAction = ActionFactory.QUIT.create(window);
        register(exitAction);

        ibovespaViewAction = new IbovespaViewAction(window, "Indice da Bovespa", IbovespaView.ID);
        register(ibovespaViewAction);
    }

    protected void fillMenuBar(IMenuManager menuBar) {
        MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
        menuBar.add(fileMenu);
        // File
        fileMenu.add(ibovespaViewAction);
        fileMenu.add(new Separator());
        fileMenu.add(exitAction);
    }

}
